package com.neuedu.collection.set;

import java.util.*;

public class SetDemo {
    public static void main(String[] args) {

        Set<String> set = new TreeSet<>();
        set.add("张三疯");
        set.add("章子怡");
        set.add("拜登");
        System.out.println(set);
        System.out.println(set.size());
        System.out.println(set.contains("拜登"));
        System.out.println(set.toArray());
        Object [] arr = set.toArray();
        for (Object  obj:  arr
             ) {
            System.out.println(obj.toString());
        }
        Iterator<String>  it=  set. iterator();
        while(it.hasNext()){
            String str = it.next();
            System.out.println(str);
        }
        System.out.println("===============");
        Set set2 = new HashSet();
        set2.add(20);
        set2.add(new Integer(100));
        set2.add("张三");
        set2.add(new Date());
        System.out.println(set2);
//        set2.add(set);  ///[张三, [张三疯, 拜登, 章子怡], 20, 100, Thu Oct 19 09:02:40 CST 2023]
        set2.addAll(set);///[张三, 拜登, 20, 100, 张三疯, 章子怡, Thu Oct 19 09:03:30 CST 2023]
        System.out.println(set2);
        System.out.println(set2.size());
        System.out.println(set2.isEmpty());
//        set2.clear();
        System.out.println(set2.isEmpty());
        set2.remove("张三疯");
        System.out.println(set2);





    }
}
